package com.syaccp.controller;

import com.syaccp.model.TOrderCategory;
import com.syaccp.service.OrderDataGatheringVoService;
import com.syaccp.service.TOrderCategoryService;
import com.syaccp.utils.Result;
import com.syaccp.vo.OrderDataGatheringVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("/api/orderDataGathering")
@Api(tags = "订单数据收集控制器")
public class OrderDataGatheringController {

    @Resource
    OrderDataGatheringVoService voService;

    @Resource
    TOrderCategoryService TOrderCategoryService;


    @GetMapping("/gerAllOrderData")
    @ApiOperation(value = "获取所有订单数据")
    public Result<OrderDataGatheringVo> gerAllOrderData() {
        OrderDataGatheringVo odg = new OrderDataGatheringVo();
        odg.setMonthOrderMoneySum(voService.getMonthOrderMoneySum())
                .setTodayOrderManySum(voService.getTodayOrderManySum())
                .setTodayOrderMoneySum(voService.getTodayOrderMoneySum())
                .setTotalOrderMoneySum(voService.getTotalOrderMoneySum())
                .setOrderTotalCount(voService.getOrderTotalCount())
                .setPlaceOrderStatusCount(voService.getPlaceOrderStatusCount())
                .setSuccessOrderStatusCount(voService.getSuccessOrderStatusCount())
                .setFailOrderStatusCount(voService.getFailOrderStatusCount());
        return Result.success(odg);
    }

    @GetMapping("/gerOrderCategory")
    @ApiOperation(value = "获取所有订单素材分类")
    public Result<List<TOrderCategory>> gerOrderCategory() {
        return Result.success(TOrderCategoryService.queryTotalLevelOrderCategory());
    }

}
